home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13833 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: erich.triumf.ca!bennett
  2. From: bennett@erich.triumf.ca (P.Bennett)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: A weird thing about printf()
  5. Date: 10 Apr 1996 07:46 PST
  6. Organization: TRIUMF: Tri-University Meson Facility
  7. Distribution: world
  8. Message-ID: <10APR199607465823@erich.triumf.ca>
  9. References: <4kflr2$5if@dewey.csun.edu>
  10. NNTP-Posting-Host: ftp.triumf.ca
  11. News-Software: VAX/VMS VNEWS 1.50    
  12.  
  13. In article <4kflr2$5if@dewey.csun.edu>, kc44097@csun.edu (chen) writes...
  14.  
  15. >#include <stdio.h>
  16. >int answer;
  17. >main()
  18. >{
  19. >  answer=2+2;
  20. >  printf("The answer is %d\n");
  21. >  return 0;
  22. >}
  23. >  In printf(),I lost "answer" in the end,but it works,and give me the
  24. >result 0.I wonder how the compiler handle this condition.Also,is this
  25. >allow by C?(by this, I mean is this a leagal usage in language itself,
  26. >or just a mistake cause by the compiler?)
  27.  
  28. Many compilers don't check that you gave printf() the appropriate type or
  29. number of arguments to match the print specifiers, so they won't give any error
  30. or warning message for this.
  31.  
  32. It's a mistake by the _programmer_, not by the compiler.
  33.  
  34. Peter Bennett VE7CEI                | Vessels shall be deemed to be in sight
  35. Internet: bennett@triumf.ca         | of one another only when one can be
  36. Packet: ve7cei@ve7kit.#vanc.bc.ca   | observed visually from the other
  37. TRIUMF, Vancouver, B.C., Canada     |                          ColRegs 3(k)
  38. GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
  39. or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
  40.  
  41.  
  42.  
  43.  
  44.